<?php

namespace plugin\agent\app\model;

use app\model\pms\Goods;
use think\Model;

/**
 * t_agent_goods 分销商品表
 * @property integer $id id(主键)
 * @property integer $goods_id 商品的id
 * @property string $type 1使用规则配置 2独立设置
 * @property string $create_time 创建时间
 * @property string $update_time 更新时间
 * @property float $one_rate 一级比例(单位:百分比)
 * @property float $two_rate 二级比例(单位:百分比)
 * @property float $three_rate 三级比例(单位:百分比)
 * @property int $rule_id 规则配置id
 */
class AgentGoods extends Model
{
    /**
     * The connection name for the model.
     *
     * @var string|null
     */
    protected $connection = 'mysql';

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 't_agent_goods';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $pk = 'id';

    public function goods()
    {
        return $this->hasOne(Goods::class, 'id', 'goods_id');
    }

    public function rule()
    {
        return $this->hasOne(AgentRule::class, 'id', 'rule_id');
    }
}
